package com.glodon.fansi.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.fansi.db.dao.FansiMapper;
import com.glodon.fansi.db.model.FansiWithBLOBs;

@Service
public class FansiService {
	@Autowired
	private FansiMapper fansiMapper;

	public int newFansi(FansiWithBLOBs fansiWithBLOBs) {
		return fansiMapper.insertSelective(fansiWithBLOBs);
	}

	public FansiWithBLOBs detail(Integer id) {
		return fansiMapper.selectByPrimaryKey(id);
	}

	/**
	 * 新增记录
	 * 
	 * @param fansiWithBLOBs
	 * @return
	 */
	public int save(FansiWithBLOBs fansiWithBLOBs) {
		if (fansiWithBLOBs.getCreatedate() == null) {
			fansiWithBLOBs.setCreatedate(new Date());
		}
		return fansiMapper.insertSelective(fansiWithBLOBs);
	}

	public List<FansiWithBLOBs> list(Map<String, String> param) {
		return fansiMapper.selectWithUser(param);
	}

	public int edit(FansiWithBLOBs fs) {
		return fansiMapper.updateByPrimaryKeySelective(fs);
	}

	public int delete(Integer id) {
		return fansiMapper.deleteByPrimaryKey(id);
	}
}
